package webcomponents;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.PageFactory;

public class testRadioButton {

	
	public static void main(String[] args) {
		
	
		String[] colors = {"Red", "Blue", "Green"};
		
		for(int i=0;i<=2;i++)
		{
		WebDriver driver = new FirefoxDriver();
		String baseUrl = "http://www.quackit.com/html/codes/html_radio_button.cfm";
		driver.get(baseUrl);
		
		// Initiate the page where implements radio button
		
		radioButton radiobutton = PageFactory.initElements(driver, radioButton.class);
		
		// Click one radio button 
		radiobutton.chooseColor(colors[i]);
		// Click submit button
		radiobutton.clickSubmitButton();
		// Initiate following page where shows which radio button was selected
		pageAfterSubmit pageaftersubmit = PageFactory.initElements(driver, pageAfterSubmit.class);
		
		String returnedString = pageaftersubmit.colorChosen.getText();
		// Verify that radio buttons are clicked and reflected in the following pages. 
		if(pageaftersubmit.colorChosen.getText().contains(colors[i]))
			{
			System.out.println(returnedString);
			System.out.println("Test passed.");
			}
		driver.close();
		}
		
		
	}
}
